package com.neu.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 功能点评估值实体类
 */
@Schema(description = "功能点评估值实体")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("fpa") // 数据库表名
public class FpAnalysisValue {

    @Schema(description = "评估值ID")
    @TableId(type = IdType.ASSIGN_ID)
    private int fpaid;

    @Schema(description = "关联任务ID")
    private String taskId;

    @Schema(description = "总未调整功能点")
    private float totalufp;

    @Schema(description = "开发功能点")
    private float dfp;

    @Schema(description = "gsc法计算结果")
    private int cf;

    @Schema(description = "项目阶段")
    private float s;

    // 计算 dfp 的方法
    public float calDFP(FpDIValue fpDIValue) {
        return totalufp * fpDIValue.calVAF();
    }
    /**
     * 计算规模调整因子 s
     * s = totalufp * cfnum
     * cfnum 的取值根据 cf 来确定：
     * cf = 1 -> cfnum = 2.00
     * cf = 2 -> cfnum = 1.50
     * cf = 3, cf = 4 -> cfnum = 1.26
     * cf = 5 -> cfnum = 1.00
     */
    public void cals() {
        // 根据 cf 的值设置 cfnum
        float cfnum = 1.00f; // 默认值为 1.00
        switch (cf) {
            case 1:
                cfnum = 2.00f;
                break;
            case 2:
                cfnum = 1.50f;
                break;
            case 3:
            case 4:
                cfnum = 1.26f;
                break;
            case 5:
                cfnum = 1.00f;
                break;
            default:
                throw new IllegalArgumentException("Invalid cf value: " + cf);
        }

        // 计算 s
        this.s = totalufp * cfnum;
    }
}

